import UserAPI from "@/api/coupons";
import type { UserQuery } from "@/api/user/model";
import type { IContentConfig } from "@/components/PageContent/index.vue";

const contentConfig: IContentConfig<UserQuery> = {
  pageName: "sys:user",
  table: {
    border: true,
    highlightCurrentRow: true,
  },
  indexAction: function (params) {
    if ("createAt" in params) {
      const createAt = params.createAt as string[];
      params.startTime = createAt[0];
      params.endTime = createAt[1];
      delete params.createAt;
    }
    return UserAPI.getPage(params);
  },
  deleteAction: UserAPI.deleteByIds,
  exportAction: UserAPI.export,
  pk: "id",
  toolbar: [
    "add",
    "delete",
    // "export",
    // {
    //   name: "import",
    //   icon: "upload",
    //   text: "导入",
    //   auth: "import",
    // },
  ],
  cols: [
    { type: "selection", width: 50, align: "center" },
    { label: "优惠券ID", align: "center", prop: "id", minWidth: 120 },
    { label: "优惠码", align: "center", prop: "code", minWidth: 120 },
    { label: "类型", align: "center", prop: "type", slotName: "type", templet: "custom", minWidth: 100, },
    { label: "优惠金额", align: "center", prop: "num", minWidth: 100 },
    { label: "是否长期有效", align: "center", prop: "isLongTerm", slotName: "isLongTerm", templet: "custom", width: 120 },
    { label: "失效日期", align: "center", prop: "expireDate", minWidth: 180 },
    {
      label: "操作",
      fixed: "right",
      minWidth: 150,
      templet: "tool",
      align: "center",
      operat: [
        // {
        //   name: "reset_pwd",
        //   auth: "password:reset",
        //   icon: "refresh-left",
        //   text: "重置密码",
        // },
        "edit",
        "delete",
      ],
    },
  ],
};

export default contentConfig;
